<?php
namespace app\common\validate;

/**
 * Class Category
 * @package app\common\validate
 * @author jwj <jwjbjg@gmail.com>
 * @copyright jwj
 */
class Category extends Validate
{
    protected $rule = [
        'id'          => ['require'],
        'name'        => ['require', 'max' => 32, 'unique:category'],
        'title'       => ['require', 'max' => 64],
        'thumb'       => ['max' => 255],
        'keywords'    => ['max' => 255],
        'description' => ['max' => 255],
        'status'      => ['require', 'between' => [0, 1]],
        'sort'        => ['require', 'between' => '0,99'],
    ];

    protected $field = [
        'id'          => 'ID',
        'name'        => '名称',
        'title'       => '标题',
        'thumb'       => '封面图',
        'keywords'    => '关键字',
        'description' => '描述',
        'status'      => '状态',
        'sort'        => '排序',
    ];

    public function sceneAdd()
    {
        return $this->remove('id', true);
    }

    public function sceneEdit()
    {
        return $this;
    }
}